package com.jues.huichain.login.presenter;

import com.jues.huichain.login.activity.FindPSWActivity;
import com.jues.huichain.login.entity.CodeEntity;
import com.jues.huichain.login.entity.EntranceEntity;
import com.jues.huichain.login.entity.EntranceResultEntity;
import com.jues.huichain.login.model.EntranceModel;

import health.lm.com.component_base.base.mvp.contract.XPresent;
import health.lm.com.data.App;
import health.lm.com.data.HttpCST;
import health.lm.com.network.callback.SimpleCallBack;

/**
 * 注册
 */

public class FindPSWPresenter extends XPresent<FindPSWActivity> {
    private EntranceModel mModel = new EntranceModel();

    public void findPsw( String phone, String code, String psw) {
        EntranceEntity entranceEntity = new EntranceEntity(phone, HttpCST.TYPE_FORGET,code);
        entranceEntity.setAccess_token(App.getModel().getAccess_token());
        entranceEntity.setNew_password(psw);
        entranceEntity.setConfirm_password(psw);
        mModel.forgot(entranceEntity, new SimpleCallBack<Object>() {
            @Override
            public void onSuccess(Object pO) {
                if (hasV()) getV().findPswSuccess("找回密码成功！");
            }
        });
    }

    public void getCode(String phone) {
        CodeEntity codeEntity = new CodeEntity("", phone, HttpCST.TYPE_FORGET);
        mModel.getCode(codeEntity, new SimpleCallBack<Object>() {
            @Override
            public void onSuccess(Object pO) {

            }
        });
    }
}
